package TwoSeach;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: TwoSeach
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-11-05  09:05
 * @Description: TODO
 * @Version: 1.0
 */
public class 搜索二维矩阵74 {

    // 采用斜对角的方式来实现数组的有序性质
    public boolean searchMatrix(int[][] matrix, int target) {
        int len=matrix.length-1;
        int width=matrix[0].length-1;
        int i=len;
        int j=0;
        while (i>=0&&j<=width){
            if (matrix[i][j]==target){
                return true;
            }else if (matrix[i][j]<target){
                j++;
            }else {
                i--;
            }
        }
        return false;
    }
}
